<extend name="template/base_index" />


<block name="area_header">

    <link rel="stylesheet" type="text/css" media="all" href="__CDN__/jquery-datetimepicker/jquery.datetimepicker.css">
    <script type="text/javascript" src="__CDN__/jquery-datetimepicker/jquery.datetimepicker.js"></script>

</block>

<block name="area_body">
    {:W('Menus/topbar')}
    <div class="admin-main container-fluid">
        {:W('Menus/left')}
        <div class="admin-main-content">
            {:W('Menus/breadcrumb')}
            <!-- 操作按钮 -->
            <style type="text/css">
                .modal-backdrop {
                    z-index: 1 !important;
                }
                .modal-dialog {
                    z-index: 999;
                }
            </style>
            <form action="{:U('VipManage/viplist')}" method="post" class="form-inline">
                <div class="form-group">
                    <div class="input-group">
                        <div class="input-group-addon">
                            VIP类型
                        </div>
                        <select name="vip" class="form-control" >
                            <option value="">=全部=</option>
                            <option value="-1" <if condition="$vip eq -1">selected</if>>被邀请的黄金VIP</option>
                            <option value="-2" <if condition="$vip eq -2">selected</if>>被邀请的白金VIP</option>
                            <option value="1" <if condition="$vip eq 1">selected</if>>星级VIP</option>
                            <option value="2" <if condition="$vip eq 2">selected</if>>黄金VIP</option>
                            <option value="3" <if condition="$vip eq 3">selected</if>>白金VIP</option>
                            <option value="4" <if condition="$vip eq 4">selected</if>>钻石VIP</option>
                            <option value="5" <if condition="$vip eq 5">selected</if>>天使VIP</option>
                            <option value="6" <if condition="$vip eq 6">selected</if>>股东VIP</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <div class="input-group">
                        <div class="input-group-addon">
                            昵称
                            <i class="fa fa-calendar"></i>
                        </div>
                        <input type="text" name="name" id="enddatetime" class="form-control input-short" value="{$name}" />
                    </div>
                </div>
                <button type="submit" class="btn btn-default btn-sm"><i class="fa fa-search"></i>{:L('BTN_SEARCH')}</button>
            </form>

            <table class="table table-striped table table-hover  table-condensed">
                <thead>
                <tr>
                    <th>
                        <input type="checkbox" class="selectall" onclick="myUtils.selectall(this,'.selectitem');" />
                    </th>
                    <th style="width: 240px;">
                        ID
                    </th>
                    <th>
                        昵称
                    </th>
                    <th>
                        VIP类型
                    </th>
                    <th>
                        储值
                    </th>
                    <th>
                        创建时间
                    </th>
                    <th>
                        操作
                    </th>
                </tr>
                </thead>
                <tbody>
                <empty name="list">
                    <tr>
                        <td colspan="7" class="text-center">{:L('NO_DATA')}</td>
                    </tr>
                    <else/>
                    <volist name="list" id="vo">
                        <tr>
                            <td>
                                <input type="checkbox" value="{$vo.id}" name="ids[]" class="selectitem" /></td>
                            <td>
                                {$vo.wx_id}
                            </td>
                            <td>
                                {$vo.name}
                            </td>
                            <td>
                                <if condition="$vo.role_grade eq 1 and $vo.vip_type eq 1">星级vip</if>
                                <if condition="$vo.role_grade eq 2 and $vo.vip_type eq 1">黄金vip</if>
                                <if condition="$vo.role_grade eq 3 and $vo.vip_type eq 1">白金vip</if>
                                <if condition="$vo.role_grade eq 4 and $vo.vip_type eq 1">钻石vip</if>
                                <if condition="$vo.role_grade eq 5 and $vo.vip_type eq 1">被邀请的黄金vip</if>
                                <if condition="$vo.role_grade eq 6 and $vo.vip_type eq 1">被邀请的白金vip</if>
                                <if condition="$vo.role_grade eq 1 and $vo.vip_type eq 2">天使vip</if>
                                <if condition="$vo.role_grade eq 2 and $vo.vip_type eq 2">被降级的天使vip</if>
                                <if condition="$vo.role_grade eq 1 and $vo.vip_type eq 3">股东vip</if>
                                <if condition="$vo.role_grade eq 2 and $vo.vip_type eq 3">被降级的股东vip</if>
                            </td>
                            <td>
                                {$vo['store_money']}
                            </td>
                            <td>
                                {$vo.create_time|date='Y-m-d h:i:s',###}
                            </td>
                            <td>
                                <if condition="$vo['vip_type'] neq 2"><button class="btn btn-sm btn-warning angel-btn" data-val="{$vo['wx_id']}">升为天使VIP</button></if>
                                <if condition="$vo['vip_type'] neq 3"><button class="btn btn-sm btn-danger partner-btn" data-val="{$vo['wx_id']}">升为股东VIP</button></if>
                                <a href="{:U('Admin/VipManage/edit_account',array('wx_id' => $vo['wx_id']))}" class="btn btn-sm btn-primary">修改数据</a>
                                <a href="{:U('Admin/VipManage/add_store_money',array('wx_id' => $vo['wx_id']))}" class="btn btn-sm btn-primary">增加储值</a>
                                <a href="{:U('Admin/VipManage/look_record',array('wx_id' => $vo['wx_id']))}" class="btn btn-sm btn-primary">查看储值记录</a>

                            </td>
                        </tr>
                    </volist>
                </empty>
                </tbody>
            </table>
            <div>{$show}</div>
        </div>
    </div>
    <!-- END admin-main-content -->
    </div>
    <!-- END admin-main-->
    <script type="text/javascript">
        $('.angel-btn').bind('click',function(){
            var wx_id = $(this).attr('data-val');
            var html = "<input type='hidden' name='wx_id' value='"+wx_id+"'/><br/>您确定要将改哟古湖升级成天使VIP确定的话请输入用户缴纳的金额<br/>";
            html = html+"请输入该会员缴纳的金额：<input type='text' name='money' value=''>";
            $('#angel-modal').find('.modal-body p').html(html);

            $('#angel-modal').modal();
        });

        $('.partner-btn').bind('click',function(){

            var wx_id = $(this).attr('data-val');
            var html = "<input type='hidden' name='wx_id' value='"+wx_id+"'/><br/>您确定要将改哟古湖升级成股东VIP确定的话请输入用户缴纳的金额<br/>";
            html = html+"请输入该会员缴纳的金额：<input type='text' name='money' value=''>";
            $('#partner-modal').find('.modal-body p').html(html);

            $('#partner-modal').modal();
        });

        function angelSubmit(){
            var wx_id = $('#angel-modal').find("[name='wx_id']").val();
            var money = $('#angel-modal').find("[name='money']").val();
            $.post("{:U('VipManage/riseAngel')}",{wx_id:wx_id,money:money},function(res){
                 if(res['status']){
                     window.location.reload();
                 }
             })
        }

        function partnerSubmit(){
            var wx_id = $('#partner-modal').find("[name='wx_id']").val();
            var money = $('#partner-modal').find("[name='money']").val();
            $.post("{:U('VipManage/risePartner')}",{wx_id:wx_id,money:money},function(res){
                if(res['status']){
                    window.location.reload();
                }
            })
        }

    </script>

    <!--天使模态弹窗-->
    <div class="modal fade" id="angel-modal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">系统提醒</h4>
                </div>
                <div class="modal-body">
                    <p>One fine body&hellip;</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary" onclick="angelSubmit()">确定</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <!--天使模态弹窗-->
    <div class="modal fade" id="partner-modal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">系统提醒</h4>
                </div>
                <div class="modal-body">
                    <p>One fine body&hellip;</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary" onclick="partnerSubmit()">确定</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</block>

<block name="area_footer">

</block>